package com.qihoo360.mobilesafe.opti.powerctl.ui.widget;

import com.qihoo360.mobilesafe.opti.powerctl.R;

import android.content.Context;
import android.util.AttributeSet;
import android.view.animation.LinearInterpolator;
import android.view.animation.RotateAnimation;
import android.widget.FrameLayout;
import android.widget.ImageView;

public class RotateScanAniView extends FrameLayout {

	private ImageView mPointer;

	public RotateScanAniView(Context context) {
		super(context);
		inflate(context, R.layout.rotate_scan_ani_view, this);
		mPointer = (ImageView) findViewById(R.id.img_rotate_scan_top);
	}

	public RotateScanAniView(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
		inflate(context, R.layout.rotate_scan_ani_view, this);
		mPointer = (ImageView) findViewById(R.id.img_rotate_scan_top);
	}

	public RotateScanAniView(Context context, AttributeSet attrs) {
		super(context, attrs);
		inflate(context, R.layout.rotate_scan_ani_view, this);
		mPointer = (ImageView) findViewById(R.id.img_rotate_scan_top);
	}
	
	public void startScan() {
		RotateAnimation rotateAnimation = new RotateAnimation(0f,360f,1,0.5f,1,0.5f);
		rotateAnimation.setFillEnabled(true);
		rotateAnimation.setFillAfter(true);
		LinearInterpolator  linearPolator = new LinearInterpolator();
		rotateAnimation.setInterpolator(linearPolator);
		rotateAnimation.setDuration(2000);
		rotateAnimation.setRepeatCount(100);
		rotateAnimation.setRepeatMode(1);
		mPointer.startAnimation(rotateAnimation);
	}
	
	public void stopScan()
	{
		mPointer.clearAnimation();
	}

}
